package com.ee.chat.cps.admin.controller;

import com.ee.chat.common.entity.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class IndexController {
    private Logger log = LoggerFactory.getLogger(IndexController.class);

    @RequestMapping("/")
    public String index(HttpServletRequest request){
        HttpSession session = request.getSession(true);
        Channel channelUser = (Channel) session.getAttribute("channelUser");
        if(channelUser != null){
            return "redirect:/toDashboard";
        }else{
            return "index";
        }
    }

    @RequestMapping("login")
    public String login() {
        return "login";
    }

    @RequestMapping("toDashboard")
    public String dashboard(HttpServletRequest request, Model model){
        HttpSession session = request.getSession(true);
        model.addAttribute("channelUser", session.getAttribute("channelUser"));
        return "dashboard";
    }

    @RequestMapping("toHome")
    public String toHome(){
        return "home/home";
    }

    @RequestMapping("toUpdPwd")
    public String toUpdPwd(){
        return "updPwd";
    }

    @RequestMapping("toChannelInfo")
    public String toChannelInfo(){
        return "usermanage/channel/edit";
    }

    @RequestMapping("toReport")
    public String toReport(){
        return "datareport/report/list";
    }

    @RequestMapping("toReportDetail")
    public String toReportDetail(){
        return "datareport/reportDetail/list";
    }

    @RequestMapping("toPromoteUser")
    public String toPromoteUser(){
        return "datareport/promoteUser/list";
    }

    @RequestMapping("toPromoteUrl")
    public String toPromoteUrl(){
        return "promotemanage/promote/list";
    }

    @RequestMapping("toPromoteChannel")
    public String toPromoteChannel(){
        return "promotemanage/channel/list";
    }

    @RequestMapping("toEditChannel")
    public String toEditChannel(){
        return "promotemanage/channel/edit";
    }
}
